
<!--Middle Part Start-->
<section id="maincontainer" class="container clearfix">
  <h1 class="heading1" align="center">学生考试页面</h1>
  <br/>
  <select id="papersExamine" class="heading2" style="margin-left: 35%;"></select>
  <input id="uId" type="hidden">
  <br/><br/><br/><br/>
  <input type="button" value="确定" class="btn btn-success" @click="enterExamine()" style="margin-left: 50%;"/>
</section>
<!--Middle container End-->
<script type="text/javascript">
  var examineVue = new Vue({
    el:"#maincontainer",
    data:{},
    methods: {
      initExamine: function () {
        $.ajax({
          url: "/api/approvals",
          type: "get",
          contentType: "application/json",
          success: function (result) {
            if (result.message == "您暂时无考试信息" || result.message == "无考生考试试卷"){
              layer.alert(result.message, {icon: 0});
            }
            var html = "";
            if (result.message == "进入考试"){
              // console.log(result.data);
              for (let j = 0; j < result.data.papers.length; j++) {
                html += "<option value='"+result.data.papers[j].id+"'>"+result.data.papers[j].subject+"</option>";
              }
              html += "<option selected>请选择进行考试的试卷</option>";
              $("#papersExamine").html(html);
              $("#uId").val(result.data.userId);
              html = "";
            }
          },
        });
      },
      enterExamine:function () {
        var confirmFlag = $("#papersExamine").val();
        var uId = $("#uId").val();
        // console.log("--uId---"+uId);
        // console.log(confirmFlag);
        if (confirmFlag == "请选择进行考试的试卷"){
          layer.alert("请选择进行考试的试卷", {icon: 0});
        }else {
          location.href = "/exam/testPaper?id="+confirmFlag+"&uId="+uId;
        }

      }
    },
    mounted:function () {
      this.initExamine();
    },
  });
</script>